#include <stdio.h>
#include <stdlib.h>
#include "../Includes/Driver.h"
#include "../Includes/Rendering.h"
#include "../Includes/Messaging.h"
#include <unistd.h>

/// <summary>
/// Locals
/// </summary>
static Cursor cursor =
{
	.x = 0,
	.y = 0,
	.width = 16,
	.height = 16,
	.private = NULL,
	.surface = NULL,
	.state = 0,
	.drv = NULL
};

/// <summary>
/// TODO
/// </summary>
int CRSInit(DriverPtr drv)
{
	if (drv == NULL)
		return -1;

	cursor.x = 0;
	cursor.y = 0;
	cursor.width = 16;
	cursor.height = 16;
	cursor.private = NULL;
	cursor.drv = drv;

	/* Create the cursor surface */
	if (drv->CreateSurface() < 0)
		return -2;

	return 0;
}

/// <summary>
/// TODO
/// </summary>
int CRSMove(int x, int y)
{
	if (x < 0 || y < 0)
		return -1;

	cursor.x = x;
	cursor.y = y;
	cursor.state = 1;
	cursor.drv->MoveCursor(0, 0);

	return 0;
}

/// <summary>
/// TODO
/// </summary>
int CRSMoveByMSG(void* msg)
{
	MessagePtr m;
	if ((m = (MessagePtr)msg) == NULL)
		return -1;
	CRSMove(m->param2, m->param3);
	return 0;
}

/// <summary>
/// TODO
/// </summary>
int CRSShow(void)
{
	if (cursor.state == 0)
		return -1;
	return 0;
}

/// <summary>
/// TODO
/// </summary>
int CRSHide(void)
{
	return 0;
}

/// <summary>
/// TODO
/// </summary>
int CRSExit(void)
{
	return 0;
}
